package com.shinbada.core.excel.options;

import com.shinbada.excel.config.Options;
import com.shinbada.modules.sys.entity.DictValue;
import com.shinbada.modules.sys.utils.DictUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author initcap
 * @date Created in 2020/11/11 10:37.
 */
public class DictOptions implements Options {

    private String dictType;

    @Override
    public void init(Object... value) {
        this.dictType = (String) value[0];
    }

    @Override
    public String[] get() {
        List<String> labelList = DictUtils.getDictList(dictType).stream().map(DictValue::getLabel).collect(Collectors.toList());
        return labelList.toArray(new String[labelList.size()]);
    }
}
